package com.common.base.utils;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.shiro.codec.Base64;

/**
 * @desc 密码加密工具
 * @author iuie
 * @date 2017-03-31 
 */
public class MD5Encode {
	
	private MD5Encode(){
		
	}
	
	public static String encode(String inStr) {
		String outStr = "";
	    try {
	      MessageDigest md5 = MessageDigest.getInstance("MD5");
	      byte[] output = Base64.encode(md5.digest(inStr.getBytes("utf-8")));
	      outStr = new String(output,"utf-8");
	    } catch (NoSuchAlgorithmException e) {
	      e.printStackTrace();
	    } catch (UnsupportedEncodingException e) {
	      e.printStackTrace();
	    }
	    return outStr;
	}
}
